package com.sopt.friends.sub;

import com.sopt.friends.R;
import com.sopt.friends.statics.FriendsStaticVars;
import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TabHost;
import android.widget.TextView;

public class FreshActivity extends TabActivity {
	private String curAction;

	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.sub_first);

		Button backBtn = (Button) findViewById(R.id.backButton);
		backBtn.setOnClickListener(new OnClickListener() {
			public void onClick(View v) {
				finish();
			}
		});
		
		curAction = getIntent().getAction();
		TextView head = (TextView)findViewById(R.id.headerText);
		
		
		if(Integer.parseInt(curAction)==FriendsStaticVars.ACTION_FIRST_TO_BIRTH){
			head.setText(getResources().getString(R.string.first_info_Birthday));
			initializeBirthTabs();
		}else if(Integer.parseInt(curAction)==FriendsStaticVars.ACTION_FIRST_TO_NEWS){
			head.setText(getResources().getString(R.string.first_info_News));
			initializeNewsTabs();
		}else if(Integer.parseInt(curAction)==FriendsStaticVars.ACTION_FIRST_TO_BEST){
			head.setText(getResources().getString(R.string.first_info_Best));
			initializeBestTabs();
		}else if(Integer.parseInt(curAction)==FriendsStaticVars.ACTION_FIRST_TO_RECENTLY){
			head.setText(getResources().getString(R.string.first_info_Recently));
			initializeRecentlyTabs();
		}else if(Integer.parseInt(curAction)==FriendsStaticVars.ACTION_FIRST_TO_FORGOTTON){
			head.setText(getResources().getString(R.string.first_info_Forgotten));
			initializeForgottenTabs();
		}else{
			head.setText(getResources().getString(R.string.first_info_Fresh));
			initializeFreshTabs();
		}
		
	}

	private void initializeFreshTabs() {
		TabHost tabHost = getTabHost();
		TabHost.TabSpec spec,spec2,spec3,spec4;
		Intent intent,intent2,intent3,intent4;    	
		
		intent = new Intent().setClass(FreshActivity.this,TabContentsActivity.class).setAction(curAction+"@"+FriendsStaticVars.TAB_1);
		intent2 = new Intent().setClass(FreshActivity.this,TabContentsActivity.class).setAction(curAction+"@"+FriendsStaticVars.TAB_2);
		intent3 = new Intent().setClass(FreshActivity.this,TabContentsActivity.class).setAction(curAction+"@"+FriendsStaticVars.TAB_3);
		intent4 = new Intent().setClass(FreshActivity.this,TabContentsActivity.class).setAction(curAction+"@"+FriendsStaticVars.TAB_4);
		
		spec = tabHost.newTabSpec("temp1").setIndicator(getResources().getString(R.string.tabs_recently),getResources().getDrawable(R.drawable.all)).setContent(intent);
		spec2 = tabHost.newTabSpec("temp2").setIndicator(getResources().getString(R.string.tabs_today),getResources().getDrawable(R.drawable.today)).setContent(intent2);
		spec3 = tabHost.newTabSpec("temp3").setIndicator(getResources().getString(R.string.tabs_week),getResources().getDrawable(R.drawable.tomorrow)).setContent(intent3);
		spec4 = tabHost.newTabSpec("temp4").setIndicator(getResources().getString(R.string.tabs_month),getResources().getDrawable(R.drawable.yesterday)).setContent(intent4);
		
		tabHost.addTab(spec);
		tabHost.addTab(spec2);
		tabHost.addTab(spec3);
		tabHost.addTab(spec4);
		
		tabHost.setCurrentTab(0);
	}
	
	private void initializeBirthTabs() {
		TabHost tabHost = getTabHost();
		TabHost.TabSpec spec,spec2,spec3,spec4;
		Intent intent,intent2,intent3,intent4;    	
		
		intent = new Intent().setClass(FreshActivity.this,TabContentsActivity.class).setAction(curAction+"@"+FriendsStaticVars.TAB_1);
		intent2 = new Intent().setClass(FreshActivity.this,TabContentsActivity.class).setAction(curAction+"@"+FriendsStaticVars.TAB_2);
		intent3 = new Intent().setClass(FreshActivity.this,TabContentsActivity.class).setAction(curAction+"@"+FriendsStaticVars.TAB_3);
		intent4 = new Intent().setClass(FreshActivity.this,TabContentsActivity.class).setAction(curAction+"@"+FriendsStaticVars.TAB_4);
		
		spec = tabHost.newTabSpec("temp1").setIndicator(getResources().getString(R.string.tabs_all),getResources().getDrawable(R.drawable.all)).setContent(intent);
		spec2 = tabHost.newTabSpec("temp2").setIndicator(getResources().getString(R.string.tabs_today),getResources().getDrawable(R.drawable.today)).setContent(intent2);
		spec3 = tabHost.newTabSpec("temp3").setIndicator(getResources().getString(R.string.tabs_yesterday),getResources().getDrawable(R.drawable.tomorrow)).setContent(intent3);
		spec4 = tabHost.newTabSpec("temp4").setIndicator(getResources().getString(R.string.tabs_tomorrow),getResources().getDrawable(R.drawable.yesterday)).setContent(intent4);
		
		tabHost.addTab(spec);
		tabHost.addTab(spec2);
		tabHost.addTab(spec3);
		tabHost.addTab(spec4);
		
		tabHost.setCurrentTab(0);
	}
	
	private void initializeNewsTabs() {
		TabHost tabHost = getTabHost();
		TabHost.TabSpec spec,spec2,spec3;
		Intent intent,intent2,intent3;    	
		
		intent = new Intent().setClass(FreshActivity.this,TabContentsActivity.class).setAction(curAction+"@"+FriendsStaticVars.TAB_1);
		intent2 = new Intent().setClass(FreshActivity.this,TabContentsActivity.class).setAction(curAction+"@"+FriendsStaticVars.TAB_2);
		intent3 = new Intent().setClass(FreshActivity.this,TabContentsActivity.class).setAction(curAction+"@"+FriendsStaticVars.TAB_3);
		
		spec = tabHost.newTabSpec("temp1").setIndicator(getResources().getString(R.string.tabs_twitter),getResources().getDrawable(R.drawable.today)).setContent(intent);
		spec2 = tabHost.newTabSpec("temp2").setIndicator(getResources().getString(R.string.tabs_me2day),getResources().getDrawable(R.drawable.tomorrow)).setContent(intent2);
		spec3 = tabHost.newTabSpec("temp3").setIndicator(getResources().getString(R.string.tabs_facebook),getResources().getDrawable(R.drawable.yesterday)).setContent(intent3);
		
		tabHost.addTab(spec);
		tabHost.addTab(spec2);
		tabHost.addTab(spec3);
		
		tabHost.setCurrentTab(0);
	}
	
	private void initializeBestTabs() {
		TabHost tabHost = getTabHost();
		TabHost.TabSpec spec,spec2;
		Intent intent,intent2;    	
		
		intent = new Intent().setClass(FreshActivity.this,TabContentsActivity.class).setAction(curAction+"@"+FriendsStaticVars.TAB_1);
		intent2 = new Intent().setClass(FreshActivity.this,TabContentsActivity.class).setAction(curAction+"@"+FriendsStaticVars.TAB_2);
		
		spec = tabHost.newTabSpec("temp1").setIndicator(getResources().getString(R.string.tabs_call),getResources().getDrawable(R.drawable.today)).setContent(intent);
		spec2 = tabHost.newTabSpec("temp2").setIndicator(getResources().getString(R.string.tabs_news),getResources().getDrawable(R.drawable.yesterday)).setContent(intent2);
		
		tabHost.addTab(spec);
		tabHost.addTab(spec2);
		
		tabHost.setCurrentTab(0);
	}
	
	private void initializeRecentlyTabs() {
		TabHost tabHost = getTabHost();
		TabHost.TabSpec spec,spec2,spec3;
		Intent intent,intent2,intent3;    	
		
		intent = new Intent().setClass(FreshActivity.this,TabContentsActivity.class).setAction(curAction+"@"+FriendsStaticVars.TAB_1);
		intent2 = new Intent().setClass(FreshActivity.this,TabContentsActivity.class).setAction(curAction+"@"+FriendsStaticVars.TAB_2);
		intent3 = new Intent().setClass(FreshActivity.this,TabContentsActivity.class).setAction(curAction+"@"+FriendsStaticVars.TAB_3);
		
		spec = tabHost.newTabSpec("temp1").setIndicator(getResources().getString(R.string.tabs_all),getResources().getDrawable(R.drawable.tomorrow)).setContent(intent);
		spec2 = tabHost.newTabSpec("temp2").setIndicator(getResources().getString(R.string.tabs_today),getResources().getDrawable(R.drawable.all)).setContent(intent2);
		spec3 = tabHost.newTabSpec("temp2").setIndicator(getResources().getString(R.string.tabs_yesterday),getResources().getDrawable(R.drawable.today)).setContent(intent3);
		
		tabHost.addTab(spec);
		tabHost.addTab(spec2);
		tabHost.addTab(spec3);
		
		tabHost.setCurrentTab(0);
	}
	
	private void initializeForgottenTabs() {
		TabHost tabHost = getTabHost();
		TabHost.TabSpec spec,spec2,spec3,spec4;
		Intent intent,intent2,intent3,intent4;    	
		
		intent = new Intent().setClass(FreshActivity.this,TabContentsActivity.class).setAction(curAction+"@"+FriendsStaticVars.TAB_1);
		intent2 = new Intent().setClass(FreshActivity.this,TabContentsActivity.class).setAction(curAction+"@"+FriendsStaticVars.TAB_2);
		intent3 = new Intent().setClass(FreshActivity.this,TabContentsActivity.class).setAction(curAction+"@"+FriendsStaticVars.TAB_3);
		intent4 = new Intent().setClass(FreshActivity.this,TabContentsActivity.class).setAction(curAction+"@"+FriendsStaticVars.TAB_4);
		
		spec = tabHost.newTabSpec("temp1").setIndicator(getResources().getString(R.string.tabs_never),getResources().getDrawable(R.drawable.yesterday)).setContent(intent);
		spec2 = tabHost.newTabSpec("temp2").setIndicator(getResources().getString(R.string.tabs_2weeks),getResources().getDrawable(R.drawable.all)).setContent(intent2);
		spec3 = tabHost.newTabSpec("temp3").setIndicator(getResources().getString(R.string.tabs_month),getResources().getDrawable(R.drawable.tomorrow)).setContent(intent3);
		spec4 = tabHost.newTabSpec("temp4").setIndicator(getResources().getString(R.string.tabs_half),getResources().getDrawable(R.drawable.today)).setContent(intent4);
		
		tabHost.addTab(spec);
		tabHost.addTab(spec2);
		tabHost.addTab(spec3);
		tabHost.addTab(spec4);
		
		tabHost.setCurrentTab(0);
	}

}
